package eerbaar.client.internal.exp;

import eerbaar.client.exp.ExpException;
import eerbaar.client.exp.ICmdFactory;
import eerbaar.client.exp.IEvaluator;
import eerbaar.client.exp.IExp;
import eerbaar.client.exp.INounFactory;
import eerbaar.client.exp.IOperatorFactory;
import eerbaar.client.exp.IScope;
import eerbaar.client.exp.TokenIterator;
import eerbaar.shared.tree.INode;

public class Bracket implements IEvaluator {

    private final Evaluator evaluator;

    public Bracket(INode root, ICmdFactory factory,
            IOperatorFactory operatorFactory, INounFactory nounFactory) {
        this.evaluator = new Evaluator(root, factory, operatorFactory,
                nounFactory);
    }

    @Override
    public Object calcDestination(IScope scope) {

        return this.evaluator.calcDestination(scope);
    }

    @Override
    public IScope interpret(IScope scope) throws ExpException {

        return this.evaluator.interpret(scope);
    }

    @Override
    public boolean isInteresting(String elementName) {

        return this.evaluator.isInteresting(elementName);
    }

    @Override
    public IExp parse(TokenIterator iterator) {

        this.evaluator.parse(iterator);
        return this;
    }

    @Override
    public void populateValueArea(IScope scope) {

        this.evaluator.populateValueArea(scope);
    }

    @Override
    public String toString() {
        return "bracket(" + this.evaluator + ")";
    }

    @Override
    public void updateArea(IScope scope) {

        this.evaluator.updateArea(scope);
    }

}
